/*
 * @Author: c
 * @Date: 2024-01-08 22:15:33
 * @LastEditTime: 2024-02-25 15:03:09
 * @LastEditors: c
 * @Description: 
 * @FilePath: \music-web-backend\src\core\music\category\entities\category.entity.ts
 * https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { BasicEntity } from "src/common/entity/basic.entity";
import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from "typeorm";
import { Album } from "../../album/entities/album.entity";
import { Song } from "../../song/entities/song.entity";
import { Track } from "../../track/entities/track.entity";
import { Video } from "../../video/entities/video.entity";

//歌曲分类
@Entity("category")
export class Category extends BasicEntity {

    constructor(id: number) {
        super()
        this.id = id
    }

    @PrimaryGeneratedColumn()
    id: number;
    @Column({
        name: "category_name",
        type: 'varchar',
        comment: "种类名称"
    })
    categoryName: string;

    @Column({
        name: "parent_id",
        default: 0,
        comment: '父类别ID'
    })
    parentId: number;


    @Column({
        name: "icon",
        type: 'varchar',
        nullable: true,
        default: '',
        comment: "图标"
    })
    icon: string;

    @Column({
        name: "sort",
        type: 'tinyint',
        default: 1,
        comment: "顺序"
    })
    sort: number;

    @ManyToMany(() => Track, track => track.tagList)
    tracks: Track[]

    @ManyToMany(() => Song, song => song.genre)
    songList: Song[]

    @ManyToMany(() => Video, video => video.genre)
    videoList: Video[]

    @ManyToMany(() => Album, album => album.genre)
    albumList: Album[]
}